package dovs.phases;

import dovs.*;
import dovs.analysis.*;
import dovs.node.*;
import static dovs.Util.*;

import java.util.*;

/**
 *	Compiler phase to check reachability of statements and definite return from
 *	methods and constructors.
 */
public aspect Reachability extends DepthFirstAdapter {

	// /////////////////////////////////////////////////////////////////////////
	// ERROR MESSAGES
	// /////////////////////////////////////////////////////////////////////////

	/**
	 * Reports the error that the method has a missing return statement.
	 * 
	 * @param method_or_constructor
	 *            the method missing a return statement
	 */
	@SuppressWarnings("unused")
	private static void errorMissingReturnStatement(
			MethodOrConstructor method_or_constructor) 
	{
		Errors.error(ErrorType.MISSING_RETURN_STATEMENT,
				method_or_constructor.getName(), "Missing return statement",
				false);
	}

	/**
	 * Reports the error that a statement is unreachable.
	 * 
	 * @param stm
	 *            the unreachable statement
	 */
	@SuppressWarnings("unused")
	private static void errorUnreachableStatement(PStm stm) {
		Errors.error(ErrorType.UNREACHABLE_STATEMENT, stm.getToken(),
				"Unreachable statement", false);
	}

}
